<section>
	<div class="page-header">
		<h1><?php echo $title; ?></h1>
	</div>
	
	<?php echo form_open(); ?>
		<div class="clearfix">
			<label>First Name </label>
			<div class="input">
				<input type="text" name="firstname" value="<?php echo $user['firstname']; ?>" />
			</div>
		</div>
		<div class="clearfix">
			<label>Last Name </label>
			<div class="input">
				<input type="text" name="lastname" value="<?php echo $user['lastname']; ?>" />
			</div>
		</div>
		<div class="clearfix">
			<label>Email </label>
			<div class="input">
				<input type="text" value="<?php echo $user['email']; ?>" disabled="disabled" />
			</div>
		</div>
		<div class="clearfix">
			<label>Role </label>
			<div class="input">
				<?php echo show_array_dropdown($roles, 'role_id', 'role_name', $user['role_id'], 'roles'); ?>
			</div>
		</div>
		<div class="clearfix">
			<label>Websites</label>
			<div class="input">
				<?php echo show_array_dropdown($websites, 'site_code', 'site_name', explode(',', $user['user_websites']), 'websites[]', 'websites', array('data-placeholder' => '&hellip;', 'multiple' => 1, 'style' => 'width:300px')); ?>
			</div>
		</div>
		<div class="actions">
			<button type="submit" class="btn primary">Save</button>
			<?php echo anchor('users', 'Cancel', array('class' => 'btn')); ?>
		</div>
	</form>
	
</section>

<script>
	$('form').submit(function() {
		
		if ($('#roles').val() == 1)
		{
			$('#websites_chzn').find('.active-result').click();
		}
		
	});
	
	$('#roles').change(function() {
		var a = $(this);
		
		if (a.val() == 1)
		{
			$('#websites_chzn').find('.active-result').click();
		}
	});
</script>